package immutablecollections.misc;

/**
 * Used to check for `null` and throw a {@link NullPointerException} if you try to add `null` to an `ImCollection`.
 */
@SuppressWarnings("serial")
public class NullCheck extends RuntimeException
{
    public NullCheck(String message)
    {
        super(message);
    }

    public static void check(Object thingThatShouldNotBeNull)
    {
        if (thingThatShouldNotBeNull == null)
        {
            throw new NullPointerException("ImCollections can't contain nulls");
        }
    }

    public static void checkThrowingNPE(Object thingThatShouldNotBeNull)
    {
        if (thingThatShouldNotBeNull == null)
        {
            throw new NullPointerException("ImCollections can't contain nulls");
        }
    }
}
